<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='../vue.js'></script>
</head>

<body>
    <div id='app'>
      <form action="###">
          <!-- v-model修饰符: .trim 收集表单数据的时候 取掉前后的空格 -->
          username:<input type="text" name="username" v-model.trim="userInfo.username"><br>
           <!-- v-model修饰符: .lazy 把收集表单实时收集 改为失去焦点以后才开始收集,类比js的input事件和change事件 -->
           password:<input type="password" name="password" v-model.lazy="userInfo.password"><br>
           <!-- v-model修饰符 .number 收集数据的时候直接转为number类型,如果无法转为正常的数字,则保持原来的字符串格式 -->
           age:<input type="text" name="age" v-model.number="userInfo.age">
           请选择你喜欢的城市
           <input type="checkbox" name="city" value="武汉" v-model="userInfo.city">武汉
           <input type="checkbox" name="city" value="上海" v-model="userInfo.city">上海
           <input type="checkbox" name="city" value="北京" v-model="userInfo.city">北京
           <input type="checkbox" name="city" value="深圳" v-model="userInfo.city">深圳
      </form>
    </div>
    <script>
        Vue.config.productionTip = false;
        const vm = new Vue({
            el: '#app',
            data() {
                return {
                    userInfo:{
                        username:'',
                        password:'',
                        age:null,
                        city:[]
                    }
                }
            }
        })
    </script>
</body>

</html>